from typing import *
from math import inf


class Solution:
    def findMaxForm(self, strs: List[str], m: int, n: int) -> int:
        dp = [[-inf] * (n + 1) for _ in range(m + 1)]
        dp[0][0] = 0
        mx = 0
        for v in strs:
            cnt = Counter(v)
            z, o = cnt["0"], cnt["1"]
            for i in range(m, -1, -1):
                for j in range(n, -1, -1):
                    if i - z >= 0 and j - o >= 0:
                        dp[i][j] = max(dp[i][j], dp[i - z][j - o] + 1)
                        mx = max(mx, dp[i][j])
        return mx


s = Solution()
print(s.findMaxForm(["10", "0001", "111001", "1", "0"], 5, 3))
